package io.renren.modules.evaluate.util;

import io.renren.modules.evaluate.entity.TreeNode;

import java.util.LinkedList;
import java.util.List;

public class TreeNodeUtil {
 
    public static List<TreeNode> transformData(List<TreeNode> treeNodeList, String pid){
        List<TreeNode> list=new LinkedList<TreeNode>();
        for (TreeNode node:treeNodeList){
            if (node.getPid().equals(pid)){
                node.setChildren(transformData(treeNodeList,node.getId()));
                list.add(node);
            }
        }
        System.out.println(list);
        return list;
    }

    /*
    public List<TreeNode> bulid(List<T> treeNodes, String root)
        List<T> trees = new ArrayList<>();
        for (T treeNode : treeNodes) {
            if (root.equals(treeNode.getParentId())) {
                     trees.add(treeNode);
                 }
            for (T it : treeNodes) {
                     if (it.getParentId() == treeNode.getId()) {
                             if (treeNode.getChildren() == null) {
                                    treeNode.setChildren(new ArrayList<>());
                                }
                            treeNode.add(it);
                        }
               }
         }
         return trees;
        }
*/

}